package com.mine.androidlearn.common.util;


import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.regex.Pattern;

/**
 * Created by hujianghao5 on 2018/4/10.
 */

public class Utils {



    public static String getCrashInfo(Throwable ex) {
        StringBuilder builder = new StringBuilder();
        Writer info = new StringWriter();
        PrintWriter printWriter = new PrintWriter(info);
        ex.printStackTrace(printWriter);
        Throwable cause = ex.getCause();
        while (cause != null) {
            cause.printStackTrace(printWriter);
            cause = cause.getCause();
        }
        builder.append(info.toString()).append("\n");
        return builder.toString();
    }

    public static boolean hasSpecialWord (String str) {
        Pattern p = Pattern.compile("[\\\\/:*?\"<|'%>&]+");
        return p.matcher(str).find();
    }
}
